﻿Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web

Public Class BotonAccion
  Inherits ImageButton

  Dim IDFormularioValor As String = ""
  Public Property IDFormulario() As String
    Get
      Return IDFormularioValor
    End Get
    Set(ByVal value As String)
      IDFormularioValor = value
    End Set
  End Property

  Dim IDGrillaValor As String = ""
  Public Property IDGrilla() As String
    Get
      Return IDGrillaValor
    End Get
    Set(ByVal value As String)
      IDGrillaValor = value
    End Set
  End Property

  Dim AccionValor As Funciones.Acciones = Funciones.Acciones.Nada
  Public Property Accion() As Funciones.Acciones
    Get
      Return AccionValor
    End Get
    Set(ByVal value As Funciones.Acciones)
      AccionValor = value
    End Set
  End Property

 

  Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
    Dim Grilla As String = String.Empty
    If Me.IDGrilla <> String.Empty Then
      Grilla = CType(Funciones.EncontrarControl(Me.IDGrilla, Me), ExtenderControl).TargetControlID
    End If
    Dim Formulario As String = String.Empty
    If Me.IDFormulario <> String.Empty Then
      Formulario = CType(Funciones.EncontrarControl(Me.IDFormulario, Me), ExtenderControl).TargetControlID
    End If
    If Grilla = String.Empty And Formulario = String.Empty Then
      Throw New Exception("Error en HtmlAccion " + Me.ID + ": Debe especificar una IDGrilla o IDFormulario, valido")
    Else
      Me.Attributes.Add("onclick", Funciones.SrcipAccion(Me.Accion, Grilla, Formulario))
    End If
    MyBase.Render(writer)
  End Sub

End Class


